package com.techstar.api.util;

import java.io.FileReader;
import java.io.Reader;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.techstar.common.jackson.JacksonMapper;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class JsonFormat {
	private static final ObjectMapper objectMapper = JacksonMapper.instance.objectMapper;
	
	public static void main(String[] args) {
		try {
			Reader reader = new FileReader("D:\\工作\\恒泰\\交委\\数据样例\\错误信息2.json");
			int ch = reader.read();
			StringBuffer buffer = new StringBuffer();
			while (ch != -1) { // 读取成功
				buffer.append((char) ch);
				ch = reader.read();
			}
//			System.out.println(buffer.toString());
			// 3、关闭流
			reader.close();
			String result = buffer.toString();
			JsonNode jsonNode = objectMapper.readTree(result).get("data");
			log.info(jsonNode.toString());
			try {
//				InterfaceType.DISTRICT_CONGEST_JUNCTION.setApiUrl("");
//            	InterfaceType.DISTRICT_CONGEST_JUNCTION.setClassName("");
//            	InterfaceUtils.filtrateDate(InterfaceType.DISTRICT_CONGEST_JUNCTION, DateTime.now(), jsonNode);
			}catch(Exception e) {
				e.printStackTrace();
			}
//			List<DailyLineRevenueRank> readValue= objectMapper.readValue(jsonNode.toString(), new TypeReference<List<DailyLineRevenueRank>>() {});
//			readValue.forEach(p->System.out.println(Integer.valueOf((int) p.getCreateTime().getMillis())));
//			readValue.forEach(p->System.out.println(p.getCreateTime().getMillis()));
//			System.out.println(readValue.toString());
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
}
